package com.cty.advice;

import org.apache.log4j.Logger;
import org.springframework.aop.AfterReturningAdvice;

import java.lang.reflect.Method;

/**
 * @Auther: cty
 * @Date: 2020/3/7 17:26
 * @Description:  后置通知类
 * @version: 1.0
 */
public class MyAfterAdvice implements AfterReturningAdvice {
    // 获取日志对象
    Logger log = Logger.getLogger(MyAfterAdvice.class);

    /**
     * 后置通知方法
     * @param o  切点方法返回值
     * @param method  切点方法的Method对象
     * @param objects  切点方法的参数
     * @param o1  切点所在对象
     * @throws Throwable
     */
    @Override
    public void afterReturning(Object o, Method method, Object[] objects, Object o1) throws Throwable {
        log.debug("后置通知-Schema-based");
        log.debug("切点返回值："+o);
        log.debug("切点方法名："+method.getName());        
        for(Object obj:objects){
            log.debug("切点方法参数："+obj.toString());
        }
        log.debug("切点所在对象："+o1);
        log.debug("后置通知-end");

    }
}
